//
//  DWCityModel.m
//  OCAPPDemo
//
//  Created by 杨冬武 on 2021/6/14.
//

#import "DWCityModel.h"
#import <objc/runtime.h>

@interface DWCityModel ()

@end

@implementation DWCityModel

- (instancetype)initWithCoder:(NSCoder *)coder {
    
    if (self = [super init]) {
        self.key = [coder decodeObjectForKey:@"key"];
        self.cityName = [coder decodeObjectForKey:@"cityName"];
        self.cityID = [coder decodeObjectForKey:@"cityID"];
        self.lat = [coder decodeDoubleForKey:@"lat"];
        self.lon = [coder decodeDoubleForKey:@"lon"];
    }
    
    return self;
}

- (void)encodeWithCoder:(NSCoder *)coder {
    [coder encodeObject:self.key forKey:@"key"];
    [coder encodeObject:self.cityName forKey:@"cityName"];
    [coder encodeObject:self.cityID forKey:@"cityID"];
    [coder encodeDouble:self.lat forKey:@"lat"];
    [coder encodeDouble:self.lon forKey:@"lon"];
}

+ (BOOL)supportsSecureCoding {
    return YES;
}

- (NSString *)description {
    return [NSString stringWithFormat:@"<key = %@, cityName = %@, cityID = %@, lat = %lf, lon = %lf>", self.key, self.cityName, self.cityID, self.lat, self.lon];
}

@end
